(function(angular) {
	'use strict';
	angular.module("fs.waf").factory("intindexService", intindexService);
	intindexService.$inject = [ '$q', 'loggerFactory', 'commonService', 'ajaxServiceFactory'];
	function intindexService($q, loggerFactory, commonService, ajaxServiceFactory) {
		var log = loggerFactory.getLogger("intindexService");
		
		var ajaxService = ajaxServiceFactory.buildAjaxService({
			getCurrencyOptions : {
				url : 'do/cda/dataList/currencies',
				method : 'get'
			},
			getYesno : {
				url : 'do/cda/dataList/yesno',
				method : 'get'
			}
		});
		
		function getCurrencyOptions() {
			var defer = $q.defer();
			ajaxService.getCurrencyOptions().then(function(response) {
				defer.resolve(response ? response : {});
			});
			return defer.promise;
		};
		function getYesnoOptions() {
			var defer = $q.defer();
			ajaxService.getYesno().then(function(response) {
				defer.resolve(response ? response : {});
			});
			return defer.promise;
		};
		
		function initOptions(ctrl){
			getCurrencyOptions().then(function(response) {
				ctrl.ccyOptions = response;
			}, angular.noop);
			getYesnoOptions().then(function(response) {
				ctrl.tenorFlagOptions = response;
			}, angular.noop);
			ctrl.intIndexLookUpOptions = getIntIndexLookUpOptions();
		};
		
		function getIntIndexLookUpOptions () {
			var options = {
				"bthCallBack" : {
					"okEvent" : "vm.okEvent",
					"closeEvent" : "vm.closeEvent"
				},
				
				"id" : "cda.indexLookUp",
				"okEvent" : true,
				"cancelEvent" : false
			};
			return options;
		}
		
		function getCcyOptions() {
			var ccy = {
				"data" : [ {
					"label" : "USD",
					"value" : "USD"
				}, {
					"label" : "CNY",
					"value" : "CNY"
				} ]	
			};
			return ccy;
		}
		
		function getTenorFlagOptions() {
			var ccy = {
					"data" : [ {
						"label" : "Y",
						"value" : "Y"
					}, {
						"label" : "N",
						"value" : "N"
					} ]	
			};
			return ccy;
		}
		
		return {
			initOptions : initOptions
		};
	}
})(angular);